home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0292.ZIP / DB3NOTES.DOC < prev    next >
Text File  |  1985-06-20  |  36KB  |  964 lines

  1. dBASEIII notes .001
  2. Thomas A. Wells
  3. 146 D Street SE
  4. Washington, DC 20003
  5. (202)546-3409
  6.  
  7.      I hope that I can provide a weekly series of these notes covering my
  8. experiences as a dBASEIII programmer, giving some descriptions of problems,
  9. solutions and tips that are accumulating.
  10.      I work as a consultant and presently am spending 40+ hours per week
  11. writing programs and managing databases using primarily dBASEIII.
  12.  
  13.      This week's experiences include an especially odd occurrence.  While
  14. interactively programming along, debugging a command file for displaying
  15. numbers of items, their record numbers and certain fields, the computer
  16. displayed the error message "File is already open".  Referring to my
  17. copy of the "PRODUCT USAGE REPORT" from Ashton-Tate (see below), I found
  18. that this message should apply only if I tried to use a command file (.PRG)
  19. to call itself - which I wasn't!
  20.      There followed an hour of trying to decide what was wrong, changing
  21. EXIT statement locations in various DO WHILE loops both in the main and
  22. sub-programs, and trying to figure out why the call had worked twice
  23. immediately before the error message appeared, etc...
  24.      Finally it was time to call the A-T help line - (213)558-0086 and
  25. have your serial number handy, please - and hope a suggestion from their
  26. people would help.
  27.      After some "Have you tried..." and "Yes, I have, but what about..."
  28. iterations, I was told to boot up the backup copy of the .EXE programs.
  29. Since I'm using a PC-XT, I put the disk in drive A, typed A:DBASE and lo!
  30. Everything worked!
  31.      The final fix for the problem was to re-copy the .EXE programs back to
  32. the hard disk from the original system disk with COPY *.EXE C:.
  33.      Why did this work?  I'm not sure, but it appears that the copy of the
  34. programs on the hard disk became corrupted, possibly in the stack management
  35. area.  So far, after another week's run, no further problems have occurred.
  36.      I'm obviously not suggesting this as a fix for all programming problems,
  37. but if you're sure(?) of everything else, give it a try.
  38.      The experience leaves me a little less sure of the integrity of either
  39. dBASEIII or IBM's hard disk.  My backups have been more frequent lately...
  40.  
  41.      The PRODUCT USAGE REPORT mentioned above has been very helpful.  I was
  42. sent it on request through the Technical Assistance phone number listed above.
  43.      The last 10 pages or so list all the dBASEIII error messages and their
  44. meanings - very helpful to the programmer and, of course, left out of the
  45. original manual.
  46.      The first half of the document consists of further tips, elucidations
  47. and comments regarding installation, programming usage of the various commands,
  48. and sections on the dCONVERT and dFORMAT utilities.
  49.      I don't know whether the report is to be issued monthly or what - mine
  50. is dated October 1, 1984.  If you're seriously programming with dBASEIII,
  51. get one!
  52.      As a final though for this week, using Wordstar with the program has
  53. been easy and helpful.    Linking the two programs requires nothing more than
  54. creating a CONFIG.DB file with the statements WP = WS and TEDIT = WS in it.
  55. Be sure and run the Wordstar INSTALL program on the version you want to use
  56. before you do, so it will come up running in the non-document mode (menu E,
  57. letter C does the trick).
  58.  
  59. Until next week -
  60.  
  61.  
  62. dBASEIII notes .002
  63. Thomas A. Wells
  64. 146 D Street SE
  65. Washington, DC 20003
  66. (202)546-3409
  67.  
  68.      I hope that I can provide a weekly series of these notes covering my
  69. experiences as a dBASEIII programmer, giving some descriptions of problems,
  70. solutions and tips that are accumulating.
  71.      I work as a consultant and presently am spending 40+ hours per week
  72. writing programs and managing databases using primarily dBASEIII.
  73.  
  74.      When adding records to a file,  I sometimes like to stop and press
  75. F4,  the function key that is programmed as "dir;".  This gives a listing of
  76. the  .DBF files only from within dBASEIII.   The first time I did this, the
  77. file I just added a record to did not show the additional record!  That is,
  78. the number of records was 89 prior to adding one, and still showed 89 after
  79. the DIR command.
  80.      The answer is relatively simple - the directory does not appear to be
  81. updated as records are added - a command to close the file seems to be
  82. required first, such as CLEAR ALL or CLOSE DABASES.
  83.      So, to see how many records have been added, issue the command CLEAR ALL
  84. (or equivalent), then DIR.
  85.      Of course, there are many other ways to determine how many records a file
  86. has while in dBASEIII - also true of nearly every way of doing almost anything.
  87. One could type GO BOTTOM, then ?RECNO().  Or if you had just added a record,
  88. ?RECNO() would work with out the GO BOTTOM. Etc...
  89.  
  90.     This week's puzzler happened while trying to index a .DBF file where the
  91. first index key was a string (character) variable, and the second key was a
  92. numeric variable.  According to the rules, the numeric variable must be con-
  93. verted to a string via the STR() function, since multiple indexing keys must
  94. all be strings.  So I did the conversion. Right in the INDEX command:
  95.  
  96.      INDEX ON string_var + STR(numeric_var) TO indexfile
  97.  
  98.      The result was puzzling, to say the least.  Examination of the file
  99. using the EDIT command showed it to be in ascending order, as advertised,
  100. with respect to the string_var, but in descending order with respect to
  101. the numeric_var!  Not what I wanted at all...
  102.      Logically,  the  conversion  to  a string    should    not  have affected
  103. order of the sort, since the numeric_var was less than 10 (single digit), and
  104. the string representation appeared to have the same number of leading blanks
  105. for each number.  Also, the ASCII value of "2" is higher than that for "1",
  106. so the blanks should not have upset the order.
  107.      The cure?    Change the field definition to "character".  Then, the
  108. indexing command becomes:
  109.  
  110.       INDEX ON string_var1 + string_var2 TO indexfile
  111.  
  112.      Examination of the ordering of the file then showed it to be organized
  113. in ascending order with respect to both keys, as intended.
  114.  
  115. Until next week...
  116.  
  117.  
  118. dBASEIII notes .003
  119. Thomas A. Wells
  120. 146 D Street SE
  121. Washington, DC 20003
  122. (202)546-3409
  123.  
  124. This week's dBASEIII raconteur-missile includes a tip for the CONFIG.DB file
  125. and some thoughts about making screen displays easier to read and maybe a
  126. little fancier with bold, underline and graphics.
  127.  
  128. CONFIG.DB
  129.   is a file that dBASEIII looks for just after you type "DBASE".  It may be
  130. used for many different purposes - listed on page B-2 of the manual - including
  131. tieing in a word processor other than the built-in one, setting most of the
  132. SET parameters and setting the function keys.
  133.  
  134. Today, let's see how it is used to set the function keys.  First, note that
  135. once again, the manual (p. 1-126) is incorrect.  There, we are told to include
  136. statements like
  137.           F2 = 'CLEAR;'
  138. to set the function keys.  Not so! If you try this, an error message will
  139. greet you, and the key will not be set...
  140.  
  141. The method used to set the function keys is illustrated by
  142.  
  143.           F2 = CLEAR;
  144.  
  145. Notice that no quotation marks are used.
  146.  
  147. Although it is not mentioned, there is a limit to the number of characters
  148. that a function key can represent.  I don't know exactly what it is, but if
  149. as an example, you try to set one key to
  150.  
  151.           F2 = SET PRINT OFF; SET DEVICE TO SCREEN;
  152.  
  153. you will find that the letters at the end, say "EEN;", have "wrapped"
  154. onto F3.  To make the above workable, use the following statement
  155.  
  156.           F2 = SET PRIN OFF;SET DEVI TO SCREE;
  157.  
  158. Note the use of the 4-letter abbreviations for the commands, and that no
  159. blank is used after the first ";".
  160.  
  161. Here's an example of a CONFIG.DB file using the above information:
  162.  
  163.       WP = WSN
  164.       TEDIT = WSN
  165.       F2 = clea all;
  166.       F3 = modi comm
  167.       F4 = set prin off;set devi to scre;
  168.  
  169. As described in an earlier note, the first two statements link WORDSTAR
  170. (INSTALLed in the non-document mode) to the MEMO field editing and the
  171. MODIFY command editing.
  172.  
  173. The last three statements set the function keys as described above.
  174.  
  175. The only invisible trick is that for the F3 key there is a blank after the
  176. word "comm ", so that all I need to do after pressing the F3 key is to
  177. type the name of the command file I wish to edit and press enter.
  178.  
  179. The possibilities for using this feature are limited only by the programmer's
  180. imagination.  If you use this feature for the final end-user program,
  181. remember that you're really trying to make life simpler for them, aren't you?
  182.  
  183.  
  184. GRAPHICS
  185.   are not too hard to do with dBASEIII.  It will, however take some patience
  186. and trial-and-error...
  187.  
  188. My system is a PC-XT with the Hercules graphics board and the IBM mono monitor.
  189. I say this because the results of the statements outlined below will surely
  190. be different if you use other hardware.
  191.  
  192. It all started with a desire to make a full screen look better, and also
  193. to make the important items stand out.
  194.  
  195. First, DFORMAT was used to draw nice boxes on the screens where they would
  196. help make things clearer.  Using DFORMAT, if anyone's interested, could be the
  197. subject of some entire later notes - it's truly an arcane challenge!  Let me
  198. know if you're curious.
  199.  
  200. After the boxes were drawn, and the .FMT file was generated, I naturally
  201. wanted to change something.  Go back to DFORMAT?  No way.  It might be made to
  202. edit an existing file, but I'm over 40 and may not have enough time left to
  203. figure out how.  So how to make changes to the graphics?
  204.  
  205. All the ASCII equivalent characters from the BASIC manual - that's how!
  206. dBASEIII will happily put any character on the screen that is on that list,
  207. so there is a copy of it hanging on the wall next to my computer.  To put
  208. a segment of a vertical double line on the screen, just enter
  209.  
  210.     ? CHR(186)
  211.  
  212. And there it is.  Of course, @ SAY may also be used.
  213.  
  214. BOLDFACE and UNDERLINE
  215.    are somewhat more involved, but easy once you get the idea.    If the SET
  216. COLOR command is properly used for your hardware, all kinds of emphasis is
  217. possible.  For you color monitor users, more experimenting will be needed.
  218. The challenge with a color monitor is not to overdo it.
  219.  
  220. Here's the trick: for my hardware (above) typing
  221.  
  222.     SET COLOR TO U1/0,0/7,0
  223.  
  224. results in everything being underlined.  Note that the second parameter 0/7
  225. leaves the @ SAY/GET reversed fields alone. Read the manual to see what is
  226. affected by each quantity between the parentheses - it's not ALWAYS wrong.
  227.  
  228. Well there is one thing wrong - or at least it "works funny" for me.  The
  229. underline is supposed to be turned on by the "U".  On my computer, the "1"
  230. turns on the underline - the "U" can be omitted.  Oh well...
  231.  
  232. To see how this can be put to use in a command file, here's one way to do it.
  233. build a .MEM file by setting the values of "b", "bu", "u" and "off" as
  234. shown
  235.  
  236.     Variable        Value
  237.        u        "SET COLOR TO U1/0,0/7,0"
  238.        off        "SET COLOR TO  7/0,0/7,0"
  239.        bu        "SET COLOR TO +1/0,0/7,0"
  240.        b        "SET COLOR TO +7/0,0/7,0"
  241.  
  242. After setting the values shown, type [SAVE TO color] [enter].
  243. Then later in a command file use the RESTORE FROM color statement to activate
  244. the variables in memory.  Don't forget the ADDITIVE modifier if other
  245. variables are active.
  246.  
  247. "off" represents the default settings; I think they're same as when dBASEIII is
  248. first started.
  249.  
  250. "u" produces underline, "bu" produces both boldface and underline, and "b"
  251. produces boldface - all on the screen, of course.
  252.  
  253. Then in a command file, or even from the dot prompt, type [&b] [enter]
  254. and everything from then 'til the [&off] occurs will be in boldface.
  255.  
  256. The underline is slightly different.  If you type [&u] [enter], every line
  257. on the screen will suddenly be underlined!  Don't worry - if the command is
  258. issued in a printed line somewhere, it'll only underline where you tell it to.
  259.  
  260. Experiment!  Impress your customers and yourself!
  261.  
  262. 'til next week...
  263.  
  264.  
  265. dBASE  III notes .004                  December    19, 1984
  266. Thomas A. Wells
  267. 146 D Street SE
  268. Washington, DC 20003
  269. (202)546-3409
  270.  
  271. This week - a newsflash, a correction and a print hint:
  272.  
  273. NEWSFLASH
  274.     Yesterday an update announcement from A-T arrived.    The offer
  275. was to upgrade to dBASE III version 1.1!
  276.     The  details are that for $25 you get the "improved"  version
  277. which  will run on the PC-AT as well as the PC & XT,  and can  be
  278. "completely installed on any hard-disk IBM PC/XT,  AT or 100% IBM
  279. PC compatible system".
  280.     The  brochure  is understandably silent as to whether or  not
  281. any  of  the bugs found by users and/or mentioned in  their  "Product
  282. Usage Report" were fixed.
  283.     My check is in the mail...
  284.     My reaction to this is that since the program has been on the
  285. market    less than 6 months,  a charge for an update is an insult.
  286. Is this tactic of charging for each item separately an    imitation
  287. of IBM?   (If the bugs are reduced, maybe it'll be worth it.)  What
  288. about  buyers  who get version 1.0 this week?    Will they  get    a
  289. "free" upgrade?  If you know anyone about to invest in dBASE III,
  290. make sure they get the word.   Surely all the present store stock
  291. hasn't been revised to version 1.1 yet.
  292.     More on this when the upgrade is received and tested.
  293.  
  294. CORRECTION
  295.     Last  note said there is no stated limit on the length of the
  296. SET FUNCTION command.  My face is red - right there on page 4-113
  297. of the manual it says 30 characters.
  298.  
  299. PRINT HINT
  300.     In formatting printouts to either/both the screen and printer
  301. it  is    useful    to be able to embed a  number  inside  text.  For
  302. example you may want to print
  303.  
  304.      "There are 12 items in this list."
  305.  
  306.     In    printing  them    or  using @  SAY,  the    numbers  will  be
  307. preceeded  by up to 7 blank spaces.   In the above example if  we
  308. issued these commands
  309.  
  310.     ? "There are"
  311.       ?? n
  312.       ?? "items in this list."
  313.  
  314.     The result would be
  315.  
  316.      There are    12items in this list.
  317.  
  318.     Note that there are 6 blanks in front of the number and  none
  319. after it.  There doesn't appear to be any simple way to eliminate the
  320. extra blanks in front of the number.  Adding one to the end is simple.
  321.     Consider the problem: if you know how long the number will be, say
  322. always 2 digits, the answer is simple.    Just convert the number to
  323. a string and use the STR() function to print only the rightmost 2
  324. characters.  But what if the number of digits varies?
  325.     Here is one way to handle that problem:
  326.  
  327.     ? "There are "
  328.       ?? STR(n,(LOG(n+.5)/LOG(10)+1))
  329.       ?? " items in this list."
  330.  
  331.     Since there doesn't seem to be any easy way within dBASE III to tell
  332. how many digits a number has, the formula above takes your number, n,
  333. and uses the LOG() function to do the job, then the STR() function to
  334. print the exact number you wanted.
  335.     The addition of the .5 to the number n is to overcome any internal
  336. inaccuracies in the LOG() function's number representation.
  337.     Oh, the result is
  338.  
  339.     There are 12 items in this list.
  340.  
  341.     Until next time...
  342.  
  343. dBASE  III notes .005                  January 15, 1984
  344. Thomas A. Wells
  345. 146 D Street SE
  346. Washington, DC 20003
  347. (202)546-3409
  348.  
  349. Sigh...
  350. Here it is one month later and the promised update to dBASE III
  351. has not yet arrived.  Maybe next month or at least Real Soon Now.
  352. Ashton-Tate has had my check that long, anyway.  If it arrives,
  353. you'll hear about it.
  354.  
  355. In the meantime, some heavy forging ahead has been done with
  356. version 1.0.  I hope version 1.1 can read the files from version
  357. 1.0 (only kidding).
  358.  
  359. This note deals with "!", "@" and "?".  No, these  aren't
  360. mumblings left over from the above carping.
  361.  
  362. "!" is a very handy tool for the dBASE III programmer.  All(?)
  363. this rascal does is run any system level program for you from
  364. within dBASE, either from the dot prompt or from within a
  365. command file.  It can be found in the manual under the
  366. equivalent syntax of "RUN".  To explain by example, here
  367. is a case study.
  368.  
  369. I got tired of typing COPY *.dbf a:, etc. at the end of every
  370. session to back up all the files that may have changed, and
  371. besides that, the end user won't want to or maybe even won't
  372. know how to.  So here's a little backup routine that can
  373. not only back up all the files, but has a little safey factor
  374. built in: if the operator puts in the wrong disk, an
  375. opportunity is given to swap it through the use of the FILE
  376. command.  Here it is:
  377.  
  378. *********************** BACKUP.PRG **************************
  379. *                                *
  380. *  Backs up .DBF, .MEM and .NDX files for the operator.     *
  381. *  An "invisible command" accessed by pressing "P" is       *
  382. *  included to back up .PRG and .FMT files.  This program   *
  383. *  checks to see whether the proper disk is put in drive A  *
  384. *  and gives a chance to abort before the copying begins.   *
  385. *                                *
  386. *************************************************************
  387.  
  388. CLEAR ALL
  389. CLEAR
  390. SET TALK OFF
  391.  
  392. @ 10,10 SAY "Insert the backup disk into Drive A."
  393. @ 12,10 SAY 'Press "B" to begin, "A" to abort'
  394. WAIT SPACE(21) to j
  395. j = UPPER(j)
  396.  
  397. * Turn the VERIFY function of DOS ON
  398. ! VERIFY ON
  399.  
  400. DO CASE j
  401.   CASE j = "B"
  402.     * Check to see if correct backup disk is in drive A:
  403.     IF FILE ("A:filename.DBF")
  404.       SET CONSOLE OFF
  405.       * Copy all the database & related files
  406.       !COPY *.DBF A:
  407.       !COPY *.MEM A:
  408.       !COPY *.NDX A:
  409.       SET CONSOLE ON
  410.     ELSE
  411.       * Argue if the disk isn't recognized...
  412.       @ 12,10 CLEAR
  413.       * Turn the bright letters on (see earlier note)
  414.       &b
  415.       @ 12,10 SAY 'This disk may not be the correct one!'
  416.       &off
  417.       @ 14,10 SAY 'When the correct one is inserted, press "B"'
  418.       @ 16,10 SAY 'To Abort, press "A"'
  419.       WAIT SPACE(31) TO b
  420.       b = UPPER(b)
  421.       DO CASE b
  422.      CASE b = "B"
  423.        SET CONSOLE OFF
  424.        !COPY *.DBF A:
  425.        !COPY *.MEM A:
  426.        !COPY *.NDX A:
  427.        SET CONSOLE ON
  428.      CASE b = "A"
  429.        RETURN
  430.       ENDCASE b
  431.    CASE j = "A"
  432.       RETURN
  433.    * This choice backs up the program and format files
  434.    CASE j = "P" .AND. FILE('A:filename.PRG')
  435.        !COPY *.PRG A:
  436.        !COPY *.FMT A:
  437. ENDCASE j
  438.  
  439. SET TALK ON
  440. SET CONSOLE ON
  441. !VERIFY OFF
  442.  
  443. RETURN
  444.  
  445. If your program files or database files are changed often, this
  446. little program saves a lot of work.  The other possibilities for
  447. using "!" (or "RUN", if you must) are intriguing.  How about a
  448. communications program or another DOS function or ... ?
  449.  
  450. "@" and "?" can both be used to print reports, among other
  451. things.
  452.  
  453. "?" is preceded by a linefeed and a carriage return <CR>,
  454. while "??" is not.  Together these two can be used to
  455. print many parts of any report, such as headings.
  456.  
  457. Where formatted fields such as telephone numbers, dates
  458. or dollar amounts are to be printed, the PICTURE clause
  459. is handy, and "@" is probably easier to use.
  460.  
  461. To have the output of both "?" and "@" routed to the
  462. printer, it is probably safer to use:
  463.  
  464.    SET PRINT ON
  465.    SET DEVICE TO PRINT
  466.  
  467. Then anything that either "@ SAY" or "?" does, is done by
  468. the printer and not the console screen.  "@ GET" is ignored.
  469.  
  470. Watch out for putting the "@" commands into a sequence that
  471. causes the printer to back up, either a line or space(s) on
  472. a line.  You may get an unwanted EJECT by the printer.
  473.  
  474. Here's an example of the use of a mixture of these commands:
  475.  
  476. * Printer codes
  477. bold_on = CHR(27) + CHR(88) + CHR(49)
  478. bold_off = CHR(27) + CHR(88) + CHR(48)
  479.  
  480. ? bold_on
  481.   ?? heading
  482.   ?? SPACE(20) + DTOC(DATE())
  483.   ?
  484.   ? bold_off
  485.    @ PROW(),0 SAY id_number PICTURE "@R 99-(999)-99"
  486.    @ PROW(),PCOL()+2 SAY id_number_2 PICTURE "@R 99/999/A"
  487.    @ PROW(),PCOL()+2 SAY SUBSTR(var1,1,14)
  488.    @ PROW(),PCOL()+2 SAY var2 + ". " + var3
  489.    @ PROW(),PCOL()+2 SAY SUBSTR(var4,1,1) + ". " + var5
  490.    @ PROW(),PCOL() SAY RECNO()
  491.    ?
  492.  
  493. In the example, the variables bold_on and bold_off are printer
  494. control codes covered in an earlier note, if memory serves.
  495.  
  496. PROW() keeps the cursor on the same line.  PCOL()+n spaces the data to
  497. match the heading.  Either "?" or "@" could have been used to
  498. print var1 - var5 and RECNO().
  499.  
  500. The  final "?" is to move the cursor to the beginning of the next
  501. line.  Without it, any subsequent output will start at the end
  502. of RECNO().
  503.  
  504. Instead of PCOL()+n, a number may be used to select the starting
  505. column for the next item.  @ PROW(),100 will place the first
  506. character in column 100 (just be sure your printer can
  507. accommodate column 100)...
  508.  
  509. Place your collection of "?" and "@" statements inside one
  510. or more DO WHILE loops and you're set to go.
  511.  
  512. Until next time...
  513.  
  514. dBASE  III notes .006                  January 24, 1984
  515. Thomas A. Wells
  516. 146 D Street SE         (see BBS @ 321-7441 for other notes)
  517. Washington, DC 20003
  518. (202)546-3409
  519.  
  520. Version 1.1 has arrived.  Some differences noted already.
  521.  
  522. Comments this time: Installation, Autostart, dFORMAT/SED, Oops.
  523.  
  524.  
  525. INSTALLATION
  526.  
  527. Installation looks difficult, but is easy.  The trick is
  528. to follow the directions...
  529.  
  530. The bottom line is that yet another protection scheme is used,
  531. this time to allow hard disk users to boot directly from the
  532. hard disk without the system disk having to be in drive A:.
  533.  
  534. To unravel the directions, you are allowed one copy on the
  535. hard disk per system disk, apparently.    The intent is that if you
  536. want to move the software to another machine, you must
  537. "uninstall" the copy (put it back onto the system disk), then
  538. move the program to your other machine.  Ridiculous.
  539.  
  540. Even more ridiculous is A-T's statement that you may want to
  541. "uninstall" the program if "your hard disk becomes damaged"!
  542. Unfortunately they don't tell how to do this wonderful magic
  543. feat.
  544.  
  545. I'm opposed to copy protection.  There are already several small
  546. programs available for un-protecting dBASE III v1.0 - surely
  547. those for v1.1 will be soon.  It is amazing to me what grown(?)
  548. men will spend their limited time on earth doing - OK,
  549. including yours truly.
  550.  
  551.  
  552. AUTOSTART
  553.  
  554. It is now practical (and legal) to boot your database from the
  555. hard disk, using a combination of the AUTOEXEC.BAT and CONFIG.DB
  556. files.    Here's how:
  557.  
  558.       AUTOEXEC.BAT file has as its last two statements:
  559.  
  560.            CD\DBMS\DB3
  561.            dbase
  562.  
  563. The first statement changes default directory to the dBASE III
  564. directory and the last invokes the program.  Since v1.1
  565. requires no boot disk in drive A:, it comes alive and looks for
  566. a CONFIG.DB file.  Mine ends with:
  567.  
  568.       COMMAND = DO mainmenu
  569.  
  570. The result of these two additions to these files means that
  571. I can walk up to the computer, flip on the main switch and walk
  572. away.  In about two minutes (using a 640K XT), the main menu
  573. is  on    the screen waiting for my use - without ever  pressing    a
  574. key.  See page 1-126 in the manual for a little more about CONFIG.DB
  575. and at least an example of COMMAND.
  576.  
  577. dFORMAT/SED
  578.  
  579. What was dFORMAT in v1.0 is SED in v1.1.  The new(?) version
  580. looks the same as the old, but it's a different size so maybe
  581. some of the bugs have been fixed.
  582.  
  583. I liked dFORMAT so I plan to like SED.    It is a very good time-
  584. saver for creating screens for input and output.  You can even
  585. use fancy boxes!  Try it - the on-line help is good.
  586.  
  587. OOPS
  588.  
  589. After one day with v1.1, a bug appeared.  Or maybe I should call
  590. it a correction to the bug.
  591.  
  592. With v1.0, printing a date to the screen with @ SAY required a
  593. PICTURE clause like "@R 99/99/99" to get it to look like a date.
  594. On the printer, you didn't need it, which agreed with the manual
  595. (see page 4-20).  That was one page that never made
  596. itself clear to me, except it encouraged me into some trial/error
  597. that resulted in my not using any PICTURE clauses with date
  598. variables.  Except as noted above, on the screen.  If you
  599. happen to have a good explanation of page 4-20, please
  600. send it right away.
  601.  
  602. Now v1.1 works the same as the printer.  No PICTURE clauses
  603. needed on the screen.  Is that clear from the documentation?  No..
  604.  
  605. Documentation for v1.1?  Here's the total:
  606.  
  607.           Installation - 5 pages
  608.           Corrections - 4 pages (scattered items)
  609.           New pages - 1
  610.           SED comments - 4
  611.  
  612. Sometime soon it might be a good idea to funnel all the new
  613. and/or old bugs for dBASE III, particularly v1.1, to one person.
  614. The idea is to accumulate them, then forward to users groups
  615. and A-T.
  616.  
  617. Comments?
  618.  
  619. dBASE  III notes .007                        April 4, 1985
  620. Thomas A. Wells
  621. 146 D Street SE         (see BBS @ 321-7441 for other notes)
  622. Washington, DC 20003
  623. (202)546-3409
  624.  
  625. Today's a good day for some thoughts about screen and printer graphics.
  626.  
  627. As noted in earlier scribblings, I use Wordstar for all my dBASE III
  628. programming.  As a result, graphics are fairly simple to do, as I hope
  629. you'll see shortly. If you use Sidekick, or the dBASE III editor, or
  630. some other word processor the principles may or may not apply. Try
  631. it anyway.
  632.  
  633. The first problem is to get the graphics characters into the editor;
  634. that is, to make them available on the screen. I did it by using
  635. dFORMAT, supplied with v1.0. The "new" screen-making tool, SED,
  636. supplied with v1.1 will make you work harder for the same result.
  637. Or less.
  638.  
  639. The overall process for getting control of lines and boxes is:
  640.     1. Draw a box any way you can in either SED or dFORMAT.
  641.        (Or any other way - all's fair.)
  642.         2. Use SED or dFORMAT to generate the .PRG file.
  643.            (Or see above parentheses)
  644.     3. Import the .PRG file into your word processor.
  645.     4. Use your word processor's functions for copying,
  646.        moving and editing to construct other figures as needed.
  647.  
  648. If you have dFORMAT, you can generate a box completely and import the
  649. whole thing into your word processor. If you're "stuck" with SED, it's
  650. a little more arcane.
  651.  
  652. Here's a short list of keys and their effect on the screen for those
  653. with SED:
  654.     Key    CHR()        Key    CHR()
  655.     F1    187        F2    200
  656.     F3    189        F4    190
  657.     F5    191        F6    192
  658.  
  659. And so on...
  660. Refer to your BASIC manual for the figures represented by the ASCII codes.
  661.  
  662. With SED, if you use the SHIFT, ALT and CONTROL keys with the function 
  663. keys (and even the backslash key) you can get some of the PC graphics &
  664. other special characters, but it's almost too time consuming. Besides,
  665. after all that I still wasn't able to make a complete box! The
  666. vertical line character managed to escape me completely. So I went
  667. back to dFORMAT, got both the single and double line samples, and
  668. started from there.
  669.  
  670. As another possibility, I've used Wordstar in the non-document mode to
  671. write this note, so the example below may be used, if you can ingest
  672. it with your dBASE III editor.  Here's a sample box:
  673.  
  674.  
  675.  
  676.  
  677.  
  678. @ 2,0 SAY "╔══════════════════════════════════════════════════════"
  679. @ 2,55 SAY "═══════════════════════╗"
  680. @ 3,0 SAY "║"
  681. @ 3,78 SAY "║"
  682. @ 4,0 SAY "║"
  683. @ 4,14 SAY "Whatever the TITLE of this here screen is..."
  684. @ 4,78 SAY "║"
  685. @ 5,0 SAY "║"
  686. @ 5,78 SAY "║"
  687. @ 6,0 SAY "║"
  688. @ 6,78 SAY "║"
  689. @ 7,0 SAY "║"
  690. @ 7,20 SAY "und so weiter..."
  691. @ 7,78 SAY "║"
  692. @ 8,0 SAY '║'
  693. @ 8,78 SAY "║"
  694. @ 9,0 SAY "║"
  695. @ 9,55 SAY '║'
  696. @ 10,0 SAY "║"
  697. @ 10,55 SAY "║"
  698. @ 11,0 SAY "║"
  699. @ 11,55 SAY "║"
  700. @ 12,0 SAY "║"
  701. @ 12,55 SAY "║"
  702. @ 13,0 SAY "║"
  703. @ 13,78 SAY "║"
  704. @ 14,0 SAY "║"
  705. @ 14,55 SAY "║"
  706. @ 15,0 SAY "║"
  707. @ 15,78 SAY "║"
  708. @ 16,0 SAY "║"
  709. @ 16,78 SAY "║"
  710. @ 17,0 SAY "║"
  711. @ 17,78 SAY "║"
  712. @ 18,0 SAY "║"
  713. @ 18,78 SAY "║"
  714. @ 19,0 SAY "║"
  715. @ 19,78 SAY "║"
  716. @ 20,0 SAY "║"
  717. @ 20,78 SAY "║"
  718. @ 21,0 SAY "║"
  719. @ 21,78 SAY "║"
  720. @ 22,0 SAY "║"
  721. @ 22,78 SAY "║"
  722. @ 23,0 SAY "╚══════════════════════════════════════════════════════"
  723. @ 23,55 SAY "═══════════════════════╝"
  724.  
  725. Now, the above code should, if you insert it into a .PRG or a .FMT file,
  726. produce a complete box on your screen or printer, consisting of gen - yoo -
  727. wine PC graphics characters.
  728.  
  729. If you drag this code (or the whole note) into your word processor, you
  730. may see only colons (:), H's (H), M's (M), semicolons (;), I's (I) and
  731. a less than sign (<). Don't be fooled; this is the way the graphics are
  732. displayed by Wordstar.
  733.  
  734. Don't erase one of the "graphics" colons and then try to replace it with
  735. a colon from your keyboard - life don't work that way. The ASCII codes for
  736. the "real" colon and the "graphics" colon are quite different. By about
  737. 128...
  738.  
  739. If you're still here, and have got this figure or an equivalent one into
  740. your word processor, you're ready for step 4. Move, copy and delete until
  741. you (think you) have re-formed the size and shape of your box to suit your
  742. need. Then run (DO) the program. Chase the bugs until you get it right,
  743. and spruce up all your screens.
  744.  
  745. As a side note, you can also "DO" a .FMT file! Try it.
  746.  
  747. Also note that if you have a PC "compatible" printer, both single and
  748. double line graphics will print, though most printers print either as
  749. only a single line.
  750.  
  751. Enough for now - let me know how (or if) you make out.
  752.  
  753.  
  754. dBASE  III notes .008                                 April 11, 1985
  755. Thomas A. Wells
  756. 146 D Street SE                 (see BBS @ 321-7441 for other notes)
  757. Washington, DC 20003
  758. (202)546-3409
  759.  
  760. This week's note is eclectic - PEEK and INDEXING
  761.  
  762.  
  763. PEEK
  764.  
  765.    is not documented, but a dBASE programmer can have some fun with it
  766. and perhaps learn a little about programming and screen handling in the
  767. process.  So purists are excused from reading the following example
  768. program:
  769.  
  770.  
  771. ********  PEEK.PRG
  772. * Prints the location, value & CHR() where possible
  773. * OK up to location 32767 - modify for higher locations
  774.  
  775. CLEAR
  776. INPUT "begin at ?" to begin
  777. INPUT "how many ?" to num
  778.  
  779. loc = begin
  780. r = 4
  781. c = 0
  782.  
  783. DO WHILE loc < begin + num
  784.  
  785.    * trim location number & put in proper location on screen
  786.    * see earlier note for trim technique involving logs
  787.    @ r,c*25 SAY STR(loc,(LOG(loc+.5)/LOG(10)+1))
  788.    pk = PEEK(loc)
  789.  
  790.    * take care of "unprintable" characters
  791.    IF pk > 31 .AND. pk <255
  792.       @ ROW(),COL() SAY " CHR("+STR(pk,3)+ ") = "+CHR(pk)
  793.    ELSE
  794.       IF pk <> 0
  795.           @ ROW(),COL() SAY " CHR("+STR(pk,3) + ")"
  796.       ELSE
  797.           @ ROW(),COL() SAY " CHR(  0)"
  798.       ENDIF
  799.    ENDIF
  800.  
  801.    loc = loc + 1
  802.  
  803.    * print downward on screen
  804.    r = r + 1
  805.  
  806.    * don't go off the bottom of the screen
  807.    IF r > 22
  808.       r = 4
  809.       c = c + 1
  810.  
  811. * don't go off the right of the screen
  812.          IF c > 2
  813.             c = 0
  814.             WAIT
  815.             @ 4,0 CLEAR
  816.          ENDIF
  817.    ENDIF
  818.  
  819. ENDDO
  820.  
  821. * don't overwrite data on the screen when finished
  822. @ 23,0 SAY ""
  823.  
  824.  
  825.  
  826.   If you trim the above program out of this note and run it, you will
  827. see:  - a request for the locations you want printed on the screen
  828.       - a request for the number of locations after the start above
  829.       - columns of data printed
  830.  
  831.    The programming techniques used are:
  832.       - printing in columns because they're easier to read than rows
  833.       - showing the ASCII representation where possible
  834.       - managing to stay on the screen, avoiding errors
  835.  
  836.    There are two challenges here I'd like to offer. First, see if you
  837. can make the program work above location 32767. Second, with the start
  838. given, write a disassembler! At least for the memory locations below
  839. 32768; you could use a .dbf to store the opcodes and the associated
  840. decimal & hex values... Silly?  Maybe not, if you consider it a way
  841. to learn.
  842.  
  843.  
  844. INDEXING
  845.  
  846.    can be very helpful for quick access to data in any order, and is
  847. necessary for certain other commands such as SEEK, FIND, SET INDEX
  848. and SET RELATION.
  849.  
  850.    Once a file is INDEXed, it is important to back up the .ndx file
  851. whenever the .dbf file is backed up. If you don't back it up, loss
  852. of a disk will mean reconstructing the .ndx file. If you know what
  853. the index key fields were, either from experience or documentation
  854. then rebuilding the index file is only time consuming. If you
  855. don't know what the key fields were, your problem could be quite
  856. substantial.
  857.  
  858.    One way to avoid the problem is to keep track of the .ndx file
  859. keys. Here's one way to do it:
  860.  
  861.    First, back up your .ndx files along with the associated .dbf files.
  862. A suggested "easy" way to do this is contained in an earlier note.
  863.  
  864.    Second, keep printed copies of your file structures handy by issuing
  865. the command "LIST STRUCTURE TO PRINT" every time you modify the file's
  866. structure. Then after each time you create an index file for the .dbf
  867. file, type "USE filename INDEX indexname" then press F6 (DISPLAY STATUS)
  868. to show the file in use. Note that the .ndx file's name and key fields
  869. are also shown. Do a screen print or "DISPLAY STATUS TO PRINT" and 
  870. tape the index file info to the printout of the .dbf file structure.
  871.  
  872.    This process is actually quite easy. Try it and see...
  873.  
  874.    As a related item, remember to back up any related .mem and .dbt
  875. files along with the above. To quote Macpherson's Law: "Murphy's
  876. Law is too optimistic.".
  877.  
  878.  
  879. dBASE  III notes .008                                 April 30, 1985
  880. Thomas A. Wells
  881. 146 D Street SE                 (see BBS @ 321-7441 for other notes)
  882. Washington, DC 20003
  883. (202)546-3409
  884.  
  885. This week's note concerns the "&" and the "*"
  886.  
  887. &
  888.     is the dBASE MACRO FUNCTION. It looks like an ampersand (because it
  889. is!) and works in ways that new dBASE programmers sometimes have a lot of
  890. trouble figuring out, so stay tuned for some learning by example...
  891.  
  892.     First try the program below. It's short but it illustrates the use of
  893. the "&" and also the asterisk or NOTE function:
  894.  
  895.  
  896. **************** ASTERISK.prg
  897. *  demonstrates the "&" and the "*"
  898. *  try it.
  899. ****************
  900.  
  901.  
  902. a = "*"
  903.  
  904. ? "a" + "&a"
  905.  
  906. &a ? "This is line 1"
  907.  
  908. a = ""
  909.  
  910. &a ? "This is line 2"
  911.  
  912.  
  913.     First of all the "*" (NOTE) function; if the keyword (NOTE) or the
  914. asterisk symbol appears in the first column of a line, dBASE ignores
  915. the rest of the line. Same as the REM keyword or the apostrophe does
  916. in many versions of BASIC. You knew that, of course, and use them freely
  917. in all your programs to make them crystal clear. Good show.
  918.  
  919. When you run ASTERISK.prg this is what takes place:
  920.  
  921. 1 - the variable "a" is set equal to an asterisk.
  922.  
  923. 2 - the first print statement prints an "a" and then "the contents of a".
  924.     If you think of the "&" symbol as "the contents of" it may help you
  925.     see what is taking place. Therefore, since "the contents of a" is
  926.     an asterisk, that's what appears on the screen.
  927.  
  928. 3 - in the next line the first expression is &a. Since the & is the
  929.     "contents of " function, the computer looks for its argument "a",
  930.     sees it is an asterisk and puts that character first on the line.
  931.     Seeing an asterisk first on a line causes the computer to see the line
  932.     as a comment and ignore it!
  933.  
  934. 4 - "a" is "nulled out", that is, "a" is set equal to null - the empty string.
  935.  
  936. 5 - nearly the same line as before except that "a" is no longer an asterisk
  937.     but a null, so the "?" or print statement is executed.
  938.  
  939.  
  940.     The program's output? Here it is:
  941.  
  942. do asterisk
  943. a*
  944. This is line 2
  945. .
  946.  
  947.     Try the program with other values for a such as *fGHY67 and 1234.
  948. Expect and interpret different results and error messages.
  949.  
  950.     When you are comfortable with &, use it in other dBASE statements
  951. such as
  952.  
  953.  
  954. SET FILTER TO fieldname = "&variable"
  955. LOCATE FOR fieldname = "&variable"
  956.  
  957. and all those other places that "the contents of" a variable are needed.
  958.  
  959.     See notes .003 and .005 for examples of other uses of the & function.
  960.  
  961.     Later...
  962.  
  963.  
  964.